package com.example.gitpart03;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import androidx.fragment.app.Fragment;
import java.util.ArrayList;
import java.util.List;

public class SecondPageFragment extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // 加载shouye_second_page.xml布局
        View view = inflater.inflate(R.layout.shouye_second_page, container, false);

        // 获取 ListView
        ListView hotProductsList = view.findViewById(R.id.hot_products_list);

        // 创建数据列表
        List<Product> productList = new ArrayList<>();
        // 添加一些示例产品
        productList.add(new Product("安姬果果杯", "￥19.8", R.drawable.yogurt_niuyouguo, "/份起"));
        productList.add(new Product("原味酸奶", "￥12.99", R.drawable.yogurt_yuanwei, "/份起"));

        // 创建适配器
        ProductAdapter adapter = new ProductAdapter(requireContext(), productList);

        // 设置适配器
        hotProductsList.setAdapter(adapter);

        return view;
    }
}